﻿using B.S.DataBase.MyProject.Domain.Materials;
using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

using T.E.ERP.Read.API.Applicantions.Command.MaterialsCommand.QueryMaterialsCommand;
using T.E.ERP.Read.API.Dtos.Dtos;

namespace T.E.ERP.Read.API.Controllers
{
    /// <summary>
    /// 物料的控制器-查询
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class MaterialsController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator"></param>
        public MaterialsController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        #region 物料动态下拉
        /// <summary>
        /// 供应方式查询
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<SupplyMethodModel>>> GetSupplyMethod([FromQuery] SupplyMethodQueryCommand command)
        {
            return mediator.Send(command);
        }
        /// <summary>
        /// 计量单位方式查询
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<UnitOfMeasurementModel>>> GetUnitOfMeasurement([FromQuery] UnitOfMeasurementQueryCommand command)
        {
            return mediator.Send(command);
        }
        /// <summary>
        /// 物料分类查询
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<MaterialsCopyDto>>> GetMaterialsCopy([FromQuery] MaterialCategoryQueryCommand command)
        {
            return mediator.Send(command);
        }


        /// <summary>
        /// 物料分类通过id查询
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<MaterialCategoryModel>>> GetMaterialsCopyById([FromQuery] MaterialCategoryByIdQueryCommand command)
        {
            return await mediator.Send(command);
        }




        /// <summary>
        /// 物料基本档查询
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<Material_BasicDtos>>> GetMaterial_Basic([FromQuery] Material_BasicQueryCommand command)
        {
            return mediator.Send(command);
        }
        #endregion


        /// <summary>
        /// 选择物料信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<Matern_Code>>> GetMatern_Code([FromQuery] Matern_CodeCommd command)
        {
            return mediator.Send(command);
        }
        
        




    }
}
